﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PocketDOHS
{
    public partial class LstTbl2 : Form
    {
        private LstTbl prevForm;
        private Cab nextForm;

        public LstTbl2(LstTbl l)
        {
            InitializeComponent();
            prevForm = l;
        }

        private void btnGravar_Click(object sender, EventArgs e)
        {
            FormsMethods.VetForms.Clear();
            //Adiciona um Inicializa e um Altera vetor para não ter problema quando instancia forms
            FormsMethods.Inicializa.Add(false);
            FormsMethods.Altera.Add(false);
            FormsMethods.VetIndex = 0;
            //Gravando vetor de Forms
            if (prevForm.cb1.Checked == true)
            {
                ExamExb examExb = new ExamExb();
                FormsMethods.VetForms.Add(examExb);
            }
            if (prevForm.cb2.Checked == true)
            {
                AvalArtTemp avalArtTemp = new AvalArtTemp(); ;
                FormsMethods.VetForms.Add(avalArtTemp);
            }
            if (prevForm.cb3.Checked == true)
            {
                MucBuc mucBuc = new MucBuc();
                FormsMethods.VetForms.Add(mucBuc);
            }
            if (prevForm.cb4.Checked == true)
            {
                OpacEsm opacEsm = new OpacEsm();
                FormsMethods.VetForms.Add(opacEsm);
            }
            if (prevForm.cb5.Checked == true)
            {
                FluoDent fluoDent = new FluoDent();
                FormsMethods.VetForms.Add(fluoDent);
            }
            if (prevForm.cb6.Checked == true)
            {
                IPC ipc = new IPC();
                FormsMethods.VetForms.Add(ipc);
            }
            if (cb7.Checked == true)
            {
                PerdaIns perdaIns = new PerdaIns();
                FormsMethods.VetForms.Add(perdaIns);
            }
            if (cb8.Checked == true)
            {
                CondDent condDent = new CondDent();
                CondDent2 condDent2 = new CondDent2();
                CondDent3 condDent3 = new CondDent3();
                CondDent4 condDent4 = new CondDent4(condDent, condDent2, condDent3);
                FormsMethods.VetForms.Add(condDent);
                FormsMethods.VetForms.Add(condDent2);
                FormsMethods.VetForms.Add(condDent3);
                FormsMethods.VetForms.Add(condDent4);
            }
            if (cb9.Checked == true)
            {
                CondProt condProt = new CondProt();
                FormsMethods.VetForms.Add(condProt);
            }
            if (cb10.Checked == true)
            {
                NecProt necProt = new NecProt();
                FormsMethods.VetForms.Add(necProt);
            }
            if (cb11.Checked == true)
            {
                AnomDent anomDent = new AnomDent();
                FormsMethods.VetForms.Add(anomDent);
            }
            if (cb12.Checked == true)
            {
                NecCuid necCuid = new NecCuid();
                FormsMethods.VetForms.Add(necCuid);
            }
            //Adiciona o restante dos InicializaForms e AlteraForms
            for (int i = 1; i < FormsMethods.VetForms.Count; i++)
            {
                FormsMethods.Inicializa.Add(false);
                FormsMethods.Altera.Add(false);
            }
            //Vai para o próximo Form
            if (FormsMethods.VetForms.Count == 0)
            {
                MessageBox.Show("Destaque pelo menos um campo...", "ATENÇÃO!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                FormsMethods.Inicializa.Clear();
                btnVoltar_Click(this, e);
            }
            else
            {
                if (nextForm == null || nextForm.IsDisposed)
                {
                    nextForm = new Cab(this);
                    nextForm.Show();
                }
                else
                    nextForm.BringToFront();
            }
        }

        private void btnVoltar_Click(object sender, EventArgs e)
        {
            prevForm.BringToFront();
        }

        private void LstTbl2_Closed(object sender, EventArgs e)
        {
            prevForm.Close();
        }


    }
}